<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>
    <link rel="stylesheet" href="/Public/Admin/css/style.css"/>
    <style>
        .layui-form .layui-form-item label.layui-form-label{width:150px}
        .layui-input, .layui-textarea{width:90%}
        #upload{background:url(/Public/Admin/images/file.png) no-repeat left center;padding-left:20px;padding-bottom:20px;display: inline-block;height: 38px;line-height: 38px;}
        .layui-form-item .title{font-size: 14px;font-weight: bold;border-bottom: 2px solid #2299ee;display: block;padding-bottom: 6px}
    </style>
</block>
<block name="content"> 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab">
                <blockquote class="layui-elem-quote news_search">
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:U('Flow/flowStep',array('flow_id'=>$flow_id))}">返回</a>
                    </div>
                </blockquote>

                <!-- 表单项 -->
                <form class="layui-form" action="">
                    <div class="inputArea">
                        <div class="layui-form-item">
                            <span class="title" style="border:0">{$info.prcs_name} - 编辑本步骤字段 <img class="pointer arrow" src="/Public/Admin/images/down.png" /></span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">可编辑字段</label>
                            <div class="layui-input-block">
                                <div class="left">
                                    <p class="head">本步骤可写字段</p>
                                    <ul>
                                        <if condition="$info['prcs_item'] neq null">
                                            <foreach name="info.prcs_item" item="item">
                                                <li class="add-step pointer" data-step="{$item}">{$item}<input type="hidden" name="prcs_item[]" value="{$item}"></li>
                                            </foreach>
                                        </if>
                                    </ul>
                                </div>
                                <div class="center">
                                    <img src="/Public/Admin/images/a-right.png" class="a-right pointer"/>
                                    <img src="/Public/Admin/images/a-left.png" class="a-left pointer"/>
                                </div>
                                <div class="right">
                                    <p class="head">备选字段</p>
                                    <ul>
                                        <foreach name="titles" item="title">
                                            <li class="flow-step pointer" data-step="{$title}">{$title}<input type="hidden" name="prcs_item[]" value=""></li>
                                        </foreach>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">自动赋值字段</label>
                            <div class="layui-input-block">
                                <div class="left">
                                    <p class="head">本步骤自动赋值字段</p>
                                    <ul>
                                        <if condition="$info['prcs_item_auto'] neq null">
                                            <foreach name="info.prcs_item_auto" item="auto">
                                                <li class="add-step pointer" data-step="{$auto}">{$auto}<input type="hidden" name="prcs_to[]" value="{$auto}"></li>
                                            </foreach>
                                        </if>
                                    </ul>
                                </div>
                                <div class="center">
                                    <img src="/Public/Admin/images/a-right.png" class="a-right pointer"/>
                                    <img src="/Public/Admin/images/a-left.png" class="a-left pointer"/>
                                </div>
                                <div class="right">
                                    <p class="head">备选字段</p>
                                    <ul>
                                        <foreach name="titles" item="title">
                                            <li class="flow-step pointer" data-step="{$title}">{$title}<input type="hidden" name="prcs_item_auto[]" value=""></li>
                                        </foreach>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" style="margin:0">
                            <label class="layui-form-label" style="padding: 9px 15px 0px 15px">是否允许编辑附件</label>
                            <div class="layui-input-block">
                                <lable class="input_lable">
                                    <input name="attach_edit_priv" type="radio" value="1" {$info['attach_edit_priv'] == 1 ? 'checked' :''} />允许
                                </lable>
                                <lable class="input_lable">
                                    <input type="radio" value="0" name="attach_edit_priv" {$info['attach_edit_priv'] == 0 ? 'checked' :''} />不允许
                                </lable>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <p class="red">说明:是否允许本步骤经办人编辑附件，可对流程发起时的附件进行修改或删除</p>
                        </div> 
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block button">
                            <a class="layui-btn btn-submit ajax-post" data-url="{:U('flowField')}" data-form="">保存</a>
                            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                        </div>
                    </div>
                    <input type="hidden" name="flow_id" value="{$flow_id}">               
                    <input type="hidden" name="prcs_id" value="{$prcs_id|default=0}">
                </form>
                <!-- 完 -->
            </div>
        </div>
    </section>
</block>
<block name="script">

    <script type="text/javascript" src="/Public/Admin/js/flow.js"></script>
    <script type="text/javascript">
//        $(initFlowStep());

        $('body').on('click', '.flow-step', function () {
            if ($(this).hasClass('check')) {
                $(this).removeClass('check');
                $(this).children('input').val('');
            } else {
                $(this).addClass('check');
                $(this).children('input').val($(this).attr('data-step'));
            }
        })
        $('.a-left').on('click', function () {
            var html = '';
            var leftThis = $(this);
            leftThis.parent().next().children('ul').find('li').each(function () {
                if ($(this).hasClass('check')) {
                    html += '<li class="pointer add-step" data-step="' + $(this).attr('data-step') + '">' + $(this).html() + '</li>';
                    $(this).remove();
                }
            })

            if (leftThis.parent().prev().find('ul li').text()) {
                leftThis.parent().prev().find('ul li:last').after(html);
            } else {
                leftThis.parent().prev().find('ul').html(html);
            }
        })

        $('body').on('click', '.add-step', function () {
            if ($(this).hasClass('check')) {
                $(this).removeClass('check');
                $(this).children('input').val('');
            } else {
                $(this).addClass('check');
                $(this).children('input').val('');
            }
        })

        $('.a-right').on('click', function () {
            var rightThis = $(this);
            rightThis.parent().prev().children('ul').find('li').each(function () {
                if ($(this).hasClass('check')) {
                    var html = '<li class="pointer flow-step" data-step="' + $(this).attr('data-step') + '">' + $(this).html() + '</li>';
                    $(this).remove();

                    if (rightThis.parent().next().find('ul li').text()) {
                        rightThis.parent().next().find('ul li:last').after(html)
                    } else {
                        rightThis.parent().next().find('ul').html(html)
                    }
                }
            })
        })

    </script>    
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
</block>
